﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using University.Workshop.Model;
using University.Workshop.DataAccess;
using University.Workshop.Business;

namespace University.Workshop.WebApp
{
    public partial class SomeoneWishList : System.Web.UI.Page
    {
        User user = new User();
        protected void Page_Load(object sender, EventArgs e)
        {
            string userId = Request["GuestUserId"];
            user = UserDataAccess.GetUserByEmail(User.Identity.Name);
            firstname.Text = user.PersonalInformation.FirstName;
            lastname.Text = user.PersonalInformation.LastName;
            address.Text = user.ContactInformation.Department;

            UserWishList userWL = new UserWishList();
            if (String.IsNullOrEmpty(userId))
                userWL = new UserWishList { UserId = user.Id };
            else
                userWL = new UserWishList { UserId = Convert.ToInt64(userId) };
            GridView1.DataSource = UserWishListManager.LoadUserWishList(userWL);
            GridView1.DataBind();
        }
        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                GridViewRow row = GridView1.SelectedRow;
                Response.Redirect("ProductSelected.aspx?ProductID=" + row.Cells[1].Text + "&ProductName=" + row.Cells[2].Text + "&ProductPrice=" + row.Cells[4].Text + "&ProductCategory=" + row.Cells[3].Text);
            }
            catch
            {
                labelMessage.Text = "No rows Selected";
            }
        }
    }
}